import 'package:base_plugin/base_plugin.dart';
import 'package:dio/dio.dart';

class HttpPreferenceService {
  static Future<Response> addUnitTypes(String unitType) {
    return BaseConfig.httpBase.postJson('/api/setting/preferences/unit_types', {
      'name': unitType,
    });
  }

  //todo update
  static Future<Response> deleteUnitTypes(String unitType) {
    return BaseConfig.httpBase.postJson('/api/setting/preferences/unit_types_delete', {
      'name': unitType,
    });
  }

  //todo update
  static Future<Response> updateUnitTypes(int unitType, String name) {
    return BaseConfig.httpBase
        .putJson('/api/setting/preferences/unit_type/$unitType', {
      'name': name,
    });
  }

  static Future<Response> updateTemplate(String type, String value) {
    return BaseConfig.httpBase.postJson('/api/setting/preferences/template', {
      'type': type,
      'value': value,
    });
  }

  static Future<Response> updatePreference(
      {String language,
      String default_currency_code,
      int default_payment_type_id,
      int tax_id,
      String date_format,
      List<String> alerts}) {
    return BaseConfig.httpBase.postJson('/api/setting/preferences', {
      'language': language,
      'default_currency_code': default_currency_code,
      'default_payment_type_id': default_payment_type_id,
      'tax_id': tax_id,
      'date_format': date_format,
      'alerts': alerts,
    });
  }
}
